package cn.zs.supply.common.utils;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class ResponseUtil {
    public static  void  setResponse(HttpServletResponse response,JSONObject object){
        ServletOutputStream out = null;
        try {
            response.setContentType("application/json;charset=UTF-8");
            response.setCharacterEncoding("UTF-8");
            response.setHeader("Content-type", "text/html;charset=UTF-8");
            out = response.getOutputStream();
            out.write(object.toString().getBytes("utf-8"));
            out.flush();
            out.close();
            return;
        } catch (IOException e) {
            try {
                out.close();
            } catch (IOException e1) {
            }
            return;
        }

    }
}